package com.tuotu.gps;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import butterknife.BindView;
import butterknife.BindViews;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class UserHelpActivity extends AppCompatActivity {

    @BindViews({R.id.layout_help_menu,R.id.layout_help_1,R.id.layout_help_2,R.id.layout_help_3,R.id.layout_help_4
            ,R.id.layout_help_5,R.id.layout_help_6,R.id.layout_help_7,R.id.layout_help_8})
    View[] mItemLayoutViews;

    private int mode=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_help);
        ButterKnife.bind(this);
    }

    @OnClick({R.id.tv_menu_1,R.id.tv_menu_2,R.id.tv_menu_3,R.id.tv_menu_4
            ,R.id.tv_menu_5,R.id.tv_menu_6,R.id.tv_menu_7,R.id.tv_menu_8})
    public void OnClick(View view){
        switch (view.getId()){
            case R.id.tv_menu_1:
                changeMode(mode,1);
                break;
            case R.id.tv_menu_2:
                changeMode(mode,2);
                break;
            case R.id.tv_menu_3:
                changeMode(mode,3);
                break;
            case R.id.tv_menu_4:
                changeMode(mode,4);
                break;
            case R.id.tv_menu_5:
                changeMode(mode,5);
                break;
            case R.id.tv_menu_6:
                changeMode(mode,6);
                break;
            case R.id.tv_menu_7:
                changeMode(mode,7);
                break;
            case R.id.tv_menu_8:
                changeMode(mode,8);
                break;

        }
    }

    private void changeMode(int mode,int mode2){
        this.mode=mode2;
        if(mode!=mode2){
            mItemLayoutViews[mode].setVisibility(View.GONE);
            mItemLayoutViews[mode2].setVisibility(View.VISIBLE);
        }
    }

    @Override
    public void onBackPressed() {
        if(mode==0){
            super.onBackPressed();
        }else {
            mItemLayoutViews[mode].setVisibility(View.GONE);
            mItemLayoutViews[0].setVisibility(View.VISIBLE);
            mode=0;
        }
    }
}
